function validate(){
	
	var ini = document.getElementById('txtIni');
	var first = document.getElementById('txtFn');
	var last = document.getElementById('txtLn');
	//var gender = document.getElementById('sltGen');
	var gender = document.getElementById('sltGen1');
	var gender = document.getElementById('sltGen2');
	//var byear = document.getElementById('sltYr');
	//var bmonth = document.getElementById('sltMon');
	var nic = document.getElementById('txtNic');
	var bdate= document.getElementById('txtBd');
	var address = document.getElementById('txtAdd');
	var contact = document.getElementById('txtCn');
	var email = document.getElementById('txtEmail');
	//var jyear = document.getElementById('sltJyr');
	//var jmonth = document.getElementById('sltJmon');
    var jdate= document.getElementById('txtJdy');
	var quali= document.getElementById('txtQuali');
	var exe= document.getElementById('txtExe');
	var cat= document.getElementById('sltCatorgery');
	
	// Check each input in the order that it appears in the form!
		if(notEmpty(first, "First Name cannot be empty")){
			 if(isAlphabet(first, "Letters only please for firstname")){
				if(notEmpty(last, "Last Name cannot be empty")){
					if(isAlphabet(last, "Letters only please for lastname")){
				       if(madeRadioSelection()){
							   if(notEmpty(bdate, "Select the Birth Date")){
										 if(notEmpty(nic, "Nic  cannot be empty")){ 
										  if(lengthRestriction(nic, 10, 10,"Nic no length should be 10")){
											  if(notEmpty(address, "Address cannot be empty")){
												 if(emptyNumeric(contact, "Contact Number should be numeric ")){
													 if(emptyLengthrestrict(contact, 10, 10,"Contact no length should be 10")){
													 if(emptyEmail(email, "Please enter a valid email address")){
											           		if(notEmpty(jdate, "Select the Joined Date")){
																	   if(notEmpty(quali, "qualification cannot be empty")){
																		   if(madeSelection(cat, "Select the Category")){

		                                                                                      loadXMLDoc();
                                                                             //return true;    
																			                   
																							   }
																	                         return false;
																							 } 
																                          return false;
																						  }
																                        return false;
																						}
					                                                                  return false;
																					  }
					                                                               return false;
																				   }
				                                                                 return false;
																			}
				                                               return false;
															   }
		                                                 return false;
														 }
	                                                 
					                             return false;
												 }
	                                      return false;
										  }
	                               return false;
								   }
		                         return false;
								 }
		                 return false;
						 }
		             return false;
					 }
	return false;
   }
   
  function loadXMLDoc()
{


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		 document.getElementById("ajaxDiv").innerHTML=xmlhttp.responseText;
         document.getElementById("myForm").reset(); 
	     document.getElementById("ajaxDiv1").innerHTML="";
	     document.getElementById("ajaxDiv2").innerHTML="";
    }
  }

    
	var ini = document.getElementById('txtIni').value;
	var first = document.getElementById('txtFn').value;
	var last = document.getElementById('txtLn').value;
	if(document.getElementById("sltGen1").checked) {
	var gender = document.getElementById('sltGen1').value ;
	}
	else
	{
    var gender = document.getElementById('sltGen2').value;
	}
	
	
	var nic = document.getElementById('txtNic').value;
	var bdate= document.getElementById('txtBd').value;
	var address = document.getElementById('txtAdd').value;
	var contact = document.getElementById('txtCn').value;
	var email = document.getElementById('txtEmail').value;
	var jdate= document.getElementById('txtJdy').value;
	var quali= document.getElementById('txtQuali').value;
	var exe= document.getElementById('txtExe').value;
	var cat= document.getElementById('sltCatorgery').value;
	
	var queryString ="?first=" + first +"&last="+last+ "&ini=" + ini +"&gender="+gender+ "&bdate="+bdate+ "&address=" + address +"&contact="+contact+ "&email=" + email + "&jdate=" + jdate+"&nic="+nic+"&quali="+quali+"&exe="+exe+"&cat="+cat;
	
xmlhttp.open("GET","../logic/add/employee_addx.php"+queryString ,true);
xmlhttp.send();
}
 

	function clearx()
{
	
	 document.getElementById("myForm").reset(); 
     document.getElementById("ajaxDiv").innerHTML="";
	 document.getElementById("ajaxDiv1").innerHTML="";
	 document.getElementById("ajaxDiv2").innerHTML="";
}


function nicload(){
		
		var nicx = document.getElementById('txtNic');
	    var nic = document.getElementById('txtNic').value;
	
	if(lengthRestriction(nicx, 10, 10,"Nic No length should be 10"))
								{
									
								if (window.XMLHttpRequest)
                            {// code for IE7+, Firefox, Chrome, Opera, Safari
                               xmlhttp=new XMLHttpRequest();
                            }
                           else
                              {// code for IE6, IE5
                              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                                }
                              xmlhttp.onreadystatechange=function()
                               {
                              if (xmlhttp.readyState==4 && xmlhttp.status==200)
                                 {
									//document.getElementById("ajaxDiv").innerHTML=xmlhttp.responseText; 
									 
                                var w=xmlhttp.responseText;
								if(w=="true"){
									document.getElementById("ajaxDiv2").innerHTML="Available Nic No ";
									document.getElementById('txtNic').value="";
									nicx.focus();
								}else{
									document.getElementById("ajaxDiv2").innerHTML=""; 
									
									}
									}
                                }
								
                               var z=document.getElementById('txtNic').value;
                               var queryString ="?nic=" + z;
                               xmlhttp.open("GET","../logic/load/employee_nic.php"+queryString,true);
                                xmlhttp.send();	  

								
								
								} 
	}
	
	
	
	
	
	function mailload()
{
	
	var emailX = document.getElementById('txtEmail');
	var emails = document.getElementById('txtEmail').value;
       if(!emails==""){
		   if (emailValidator(emailX, "not valid email address")){
			   
			   if (window.XMLHttpRequest)
                            {// code for IE7+, Firefox, Chrome, Opera, Safari
                               xmlhttp=new XMLHttpRequest();
                            }
                           else
                              {// code for IE6, IE5
                              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                                }
                              xmlhttp.onreadystatechange=function()
                               {
                              if (xmlhttp.readyState==4 && xmlhttp.status==200)
                                 {
									document.getElementById("ajaxDiv1").innerHTML=xmlhttp.responseText; 
									 
                                var x=xmlhttp.responseText;
								if(x=="true"){
									document.getElementById("ajaxDiv1").innerHTML="Available Email Address ";
									document.getElementById('txtEmail').value="";
								
								}else{
									document.getElementById("ajaxDiv1").innerHTML=""; 
									
									}
									}
                                }
								
                               var y=document.getElementById('txtEmail').value;
                               var queryString ="?email=" + y;
                               xmlhttp.open("GET","../logic/load/employee_mail.php"+queryString,true);
                                xmlhttp.send();	  

			   
			         } 
		      }

}

